const Router = require('koa-router')
const { verifyAuth } = require('../middlewares/auth.middleware')
const { avatarHandler, pictureHandler, pictureResize } = require('../middlewares/file.middleware')
const {
  saveAvatarInfo,
  savePictureInfo
} = require('../controllers/file.controller')

const fileRouter = new Router({prefix: '/upload'})


// 上传头像图片
fileRouter.post('/avatar', verifyAuth, avatarHandler, saveAvatarInfo)

// 上传动态配图
fileRouter.post('/picture', verifyAuth, pictureHandler, pictureResize, savePictureInfo)


module.exports = fileRouter